<template>
  <el-container class="main">
    <el-main>
      <EditorMain
        :show-shopping="false"
        :is-editor-back="true"
        :on-parent-return-to-list="onReturnToList"
      >
        <Classify style="margin-top: 10px" :importRes="true" />
        <div
          style="width: 95%; height: 1px; background: #cccccc; margin: 0 auto"
        ></div>
        <ImportBtn :import-parent-resources="importResources" />
      </EditorMain>
    </el-main>
  </el-container>
</template>

<script>
import EditorMain from "../../components/EditorMain";
import Classify from "../../components/res-list/Classify";
import ImportBtn from "../../components/res-list/ImportResButton";

let context;
let u;
export default {
  name: "ImportHome",
  components: { EditorMain, Classify, ImportBtn },
  data() {
    return {
      content: null,
    };
  },
  beforeCreate() {},
  created() {
    if (this.$store.state.cartShop.saveBlo) {
      this.$store.commit("resources/clearAllSelectedRes");
    }
    u = navigator.userAgent;
    new QWebChannel(qt.webChannelTransport, function (channel) {
      context = channel.objects.JSSendMessage;
    });
  },
  methods: {
    onReturnToList() {
      if (u.indexOf("Trident") > -1) {
        window.external.JSCallMFCFunctionoReturn();
      } else if (u.indexOf("AppleWebKit") > -1) {
        context.useFunction_Close(false);
      }
    },
    importResources(t) {
      // t = 'hello yuanlong';

      console.log(t);
      if (u.indexOf("Trident") > -1) {
        window.external.JSCallMFCFunctionoLoadingResource(t);
        this.$store.commit("resources/clearAllSelectedRes");
      } else if (u.indexOf("AppleWebKit") > -1) {
        context.sendResources(t);
        this.$store.commit("resources/clearAllSelectedRes");
      }
    },
  },
};
</script>

<style scoped>
.main {
  min-height: 100%;
  width: 100%;
  background: #eff3f5;
}
</style>
